﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Com.Rivyer.Web.work
{
    public partial class daydonealloverview : System.Web.UI.Page
    {
        private readonly BLL.jobdoneplanBll doneplanbll = new BLL.jobdoneplanBll();

        protected void Page_Load(object sender, EventArgs e)
        {
            //非法操作验证
            if (Session["username"] == null
                || Session["username"].ToString().Trim().Length == 0)
            {
                Response.Write("<script>top.location='./login.aspx'</script>");
            }
            else
            {
                if (new BLL.userauthorityBll().GetModel(Session["username"].ToString()).isdutymanager == 1)
                {
                    persoanlallgridview.Columns[0].Visible = true;
                }
                else
                {
                    persoanlallgridview.Columns[0].Visible = false;
                }
            }
        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            Model.useroperatelogModel logmodel = new Model.useroperatelogModel();
            logmodel.createdate = DateTime.Now;
            logmodel.operation = "下载";
            logmodel.username = Session["username"].ToString();
            logmodel.description = string.Format("所有人工作完成");
            new BLL.useroperatelogBll().Add(logmodel);
            gridExporter.WriteXlsToResponse(string.Format("{0}年{1}月{2}日所有人每日工作完成", DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day));
        }

        protected void persoanlallgridview_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            if (e.NewValues["daydone"] == null
               || e.NewValues["daydone"].ToString().Trim().Length == 0
               || e.NewValues["dayplan"] == null
               || e.NewValues["dayplan"].ToString().Trim().Length == 0)
            {
                e.Cancel = true;
            }
            else
            {
                new BLL.useroperatelogBll().AddLog(Session["username"].ToString(), "更新", "每日工作完成");
            }
        }

    }
}